import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router);
/* Layout */
import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/index',
    component: Layout,
    redirect: '/home',
    children: [{
      path: '/home',
      name: '首页',
      component: () => import('@/views/Index/Index'),
      meta: {title: '首页', icon: 'index'}
    }]
  },
  {
    path: '/usermanagement',
    component: Layout,
    redirect: '/usermanagement',
    name: 'usermanagement',
    meta: {title: '用户管理', icon: 'admin'},
    children: [
      {
        path: '/usersetting',
        name: 'usersetting',
        component: () => import('@/views/userManagement/UserSetting'),
        meta: {title: '用户管理'}
      },
      {
        path: '/userDetail',
        name: 'userDetail',
        hidden: true,
        component: () => import('@/views/userManagement/UserDetail'),
        meta: {title: '用户详情'}
      }
    ]
  },
  {
    path: '/fileManagement',
    component: Layout,
    redirect: '/fileManagement',
    children: [{
      path: '/fileList',
      name: '文件管理',
      component: () => import('@/views/fileManagement/FileList'),
      meta: {title: '文件管理', icon: 'fileManagement'}
    }]
  },
  {
    path: '/giftManagement',
    component: Layout,
    redirect: '/giftManagement',
    name: 'giftManagement',
    meta: {title: '礼物管理', icon: 'giftManagement'},
    children: [{
      path: '/giftList',
      name: '礼物列表',
      component: () => import('@/views/giftManagement/GiftList'),
      meta: {title: '礼物列表'}
    },
      {
        path: '/giveList',
        name: '礼物赠送记录',
        component: () => import('@/views/giftManagement/GiveList'),
        meta: {title: '礼物赠送记录'}
      },
      {
        path: '/expressionList',
        name: '表情列表',
        component: () => import('@/views/giftManagement/ExpressionList'),
        meta: {title: '表情列表'}
      },
      {
        path: '/ExpressionGiveList',
        name: '表情赠送记录',
        component: () => import('@/views/giftManagement/ExpressionGiveList'),
        meta: {title: '表情赠送记录'}
      }
    ]
  },
  {
    path: '/translateManagement',
    component: Layout,
    redirect: '/translateManagement',
    name: 'translateManagement',
    meta: {title: '翻译管理', icon: 'translationManagement'},
    children: [
      {
        path: '/translateList',
        name: '翻译列表',
        component: () => import('@/views/translateManagement/TranslateList'),
        meta: {title: '翻译语言列表'}
      },
      {
        path: '/translateSetting',
        name: '翻译设置',
        component: () => import('@/views/translateManagement/TranslateSetting'),
        meta: {title: '翻译设置'}
      },
    ]
  },
  {
    path: '/chatRecordManagement',
    component: Layout,
    redirect: '/chatRecordManagement',
    children: [{
      path: '/chatRecordList',
      name: '用户聊天记录',
      component: () => import('@/views/chatRecordManagement/ChatRecordList'),
      meta: {title: '用户聊天记录', icon: 'chatRecord'}
    }]
  },
  {
    path: '/userFlowRecord',
    component: Layout,
    redirect: '/userFlowRecord',
    name: 'userFlowRecord',
    meta: {title: '用户流水记录', icon: 'pipelineRecord'},
    children: [
      {
        path: '/memberVipRecord',
        name: '会员开通记录',
        component: () => import('@/views/userFlowRecord/MemberVipRecord'),
        meta: {title: '会员开通记录'}
      },
      {
        path: '/GoldChangeRecord',
        name: '金币变动记录',
        component: () => import('@/views/userFlowRecord/GoldChangeRecord'),
        meta: {title: '金币变动记录'}
      }
    ]
  },
  {
    path: '/orderManagement',
    component: Layout,
    redirect: '/orderManagement',
    name: 'orderManagement',
    meta: {title: '订单管理', icon: 'orderManagement'},
    children: [
      {
        path: '/recordOrder',
        name: '订单记录',
        component: () => import('@/views/orderManagement/RecordOrder'),
        meta: {title: '订单记录'}
      },
      {
        path: '/refundOrder',
        name: '退款记录',
        component: () => import('@/views/orderManagement/RefundOrder'),
        meta: {title: '退款记录'}
      }
    ]
  },
  {
    path: '/agentManagement',
    component: Layout,
    redirect: '/agentManagement',
    children: [{
      path: '/agentList',
      name: '代理管理',
      component: () => import('@/views/agentManagement/AgentList'),
      meta: {title: '代理管理', icon: 'agencyManagement'}
    }]
  },
  {
    path: '/setMealManagement',
    component: Layout,
    redirect: '/setMealManagement',
    name: 'setMealManagement',
    meta: {title: '升级会员与充值', icon: 'membershipAndRecharge'},
    children: [
      {
        path: '/setMealList',
        name: '会员套餐',
        component: () => import('@/views/setMealManagement/SetMealList'),
        meta: {title: '会员套餐'}
      },
      {
        path: '/rechargeList',
        name: '会员充值',
        component: () => import('@/views/setMealManagement/RechargeList'),
        meta: {title: '会员充值'}
      }
    ]
  },
  {
    path: '/agentProfitManagement',
    component: Layout,
    redirect: '/agentProfitManagement',
    name: 'agentProfitManagement',
    meta: {title: '代理分润', icon: 'agentDistribution'},
    children: [
      {
        path: '/rechargeProfitList',
        name: '充值分润',
        component: () => import('@/views/agentProfitManagement/RechargeProfitList'),
        meta: {title: '充值分润'}
      },
      {
        path: '/giftProfitList',
        name: '礼物分润',
        component: () => import('@/views/agentProfitManagement/GiftProfitList'),
        meta: {title: '礼物分润'}
      },
      {
        path: '/goldConsumption',
        name: '金币消费分润',
        component: () => import('@/views/agentProfitManagement/GoldConsumption'),
        meta: {title: '金币消费分润'}
      },
      {
        path: '/monthProfit',
        name: '代理月分润',
        component: () => import('@/views/agentProfitManagement/MonthProfit'),
        meta: {title: '代理月分润'}
      },
      {
        path: '/total',
        name: '实时统计',
        component: () => import('@/views/agentProfitManagement/Total'),
        meta: {title: '实时统计'}
      }

    ]
  },
  {
    path: '/systemManagement',
    component: Layout,
    redirect: '/systemManagement',
    name: 'systemManagement',
    meta: {title: '系统管理', icon: 'setting'},
    children: [
      {
        path: '/modifyLoginPassword',
        name: 'modifyLoginPassword',
        component: () => import('@/views/systemManagement/ModifyLoginPassword'),
        meta: {title: '修改登录密码'}
      },
      {
        path: '/systemSetting',
        name: 'systemSetting',
        component: () => import('@/views/systemManagement/SystemSetting'),
        meta: {title: '系统参数管理'}
      }
    ]
  },
  {path: '*', redirect: '/404', hidden: true},

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
]

const createRouter = () => new Router({
  // mode: 'history', // 需要后端服务支持
  scrollBehavior: () => ({y: 0}),
  routes: constantRoutes
})

const router = createRouter();

export function resetRouter() {
  const newRouter = createRouter();
  router.matcher = newRouter.matcher // reset router
}

export default router
